#pragma once

#include "types.h"
#include <Windows.h>
#include <boost/shared_ptr.hpp>
#include <boost/type_traits.hpp>

#include "dimension2d.h"
#include "vector2d.h"

namespace sol9
{
	typedef boost::shared_ptr<boost::remove_pointer<HDC>::type> hdc_ptr;

	class rasterizer
	{
	private:
		hdc_ptr primary, back;
		dimension2du size;
		u8* raster;

	public:
		rasterizer();

		bool initialize(hdc_ptr& _hdc, const dimension2du& _size);

		void beginScene();
		void endScene();

		void drawPixel(const vector2df& v);
		void drawLine(const vector2df& v1, const vector2df& v2);
		void drawCircle(const vector2df& v, f32 r);

	private:
		void _drawPixel(f32 x, f32 y);

		void _horizontalLine(f32 x1, f32 x2, f32 y);
		void _verticalLine(f32 x, f32 y1, f32 y2);
		void _bresenhamLine(f32 x1, f32 y1, f32 x2, f32 y2);

		void _circlePoint(f32 cx, f32 cy, f32 x, f32 y);
	};

} //namespace sol9